﻿Public Class FormTypeEditor

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

        If Me.txtTypeName.Text = "" Then
            MsgBox("Please input Type name!")
            Me.txtTypeName.Focus()
            Return
        End If

        Cmd.Parameters("@TypeName") = Me.txtTypeName.Text
        If Me.txtTypeId.Text = "" Then
            Cmd.ExecuteNonQuery("INSERT INTO Type VALUES(@TypeName,1);")
        Else
            Cmd.Parameters("@TypeId") = txtTypeId.Text
            Cmd.ExecuteNonQuery("UPDATE Type SET TypeName=@TypeName WHERE TypeId=@TypeId")
        End If

        Me.DialogResult = Windows.Forms.DialogResult.OK

    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click

        Me.DialogResult = Windows.Forms.DialogResult.Cancel

    End Sub
End Class